package cn.neusoft.vo;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

import cn.neusoft.domain.Dept;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

/**
 * Treeselect树结构实体类
 */
@Data
public class TreeSelect implements Serializable
{

    /** 节点ID */
    private Long value;

    /** 节点名称 */
    private String label;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY) // 序列化过程中只包含非空属性
    private List<TreeSelect> children;

    public TreeSelect()
    {

    }

    public TreeSelect(Dept dept)
    {
        this.value = dept.getDept_id();
        this.label = dept.getDept_name();
        this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }
}
